<template>
  <van-notice-bar scrollable left-icon="volume">
      当前账户：{{ userStore.userInfo.userName }} 欢迎使用重科智育云！
  </van-notice-bar>
  <!--  ID:{{ userStore.userInfo?.userId }}-->
  <!--  用户名:{{ userStore.userInfo?.userName }}-->
  <!--  <van-button @click="logout">退出登录</van-button>-->
  <van-swipe type="card" :height="160" :autoplay="3000" :loop="false" class="swipe">
    <van-swipe-item default="1"><img src="../../Assets/img/index_lb_1.jpg"></van-swipe-item>
    <van-swipe-item default="2"><img src="../../Assets/img/index_lb_2.jpg"></van-swipe-item>
    <van-swipe-item default="1"><img src="../../Assets/img/index_lb_3.jpg"></van-swipe-item>
    <van-swipe-item default="2"><img src="../../Assets/img/index_lb_4.jpg"></van-swipe-item>
  </van-swipe>
  <van-grid border :row-num="8/4" size="large">
    <van-grid-item :key="1" icon="failure" text="巡课" @click="xunke"/>
    <van-grid-item :key="2" icon="hotel-o" text="巡寝" @click="xunqin"/>
    <van-grid-item :key="3" icon="chat-o" text="导师育人" @click="dsyr"/>
    <van-grid-item :key="4" icon="friends-o" text="教师结队" @click="jstd"/>
    <van-grid-item :key="5" icon="newspaper-o" text="资源共享" @click="zygx"/>
    <van-grid-item :key="6" icon="fire-o" text="AI" @click="ai" style="color: #f33119"/>
    <!-- 只有当userType为1时才展示以下两个van-grid-item -->
    <van-grid-item v-if="userStore.userInfo?.userType === 1" :key="7" icon="chart-trending-o" text="可视化" @click="sjksh"/>
    <van-grid-item v-else :key="9" icon="wap-home-o" text="官网" @click="cqustgw"/>
    <van-grid-item v-if="userStore.userInfo?.userType === 1" :key="8" icon="records-o" text="任务发布" @click="rwfb"/>
    <!-- 占位的van-grid-item，用于保持布局 -->
    <van-grid-item v-else :key="10" icon="idcard" text="教务系统" @click="jwxt"/>
  </van-grid>
  <div class="pr"></div>
  <div class="yrcg">
    <div class="yrcg_title">
      <span class="yrcg_span">{{ yrcg }}</span>
      <span class="yrcg_more" @click="more_cg">更多成果...</span>
    </div>
    <AchievementList/>
  </div>
</template>

<script setup>
import { ref } from "vue";
import AchievementList from "./AchievementList.vue";
import { useUserStore } from '../../Store/modules/userinfo/UserInfo.js'
import { computed } from 'vue'
import { useRouter } from 'vue-router'

const userStore = useUserStore()
const router = useRouter()

const userTypeText = computed(() => {
  switch(userStore.userInfo?.userType) {
    case 1: return '领导'
    case 2: return '辅导员'
    case 3: return '教师'
    default: return '未知身份'
  }
})

// 退出登录
const logout = () => {
  userStore.clearUser()
  router.push('/')
}
// // 查看成功没有
// console.log('当前用户:', JSON.parse(JSON.stringify(userStore.userInfo)))

const yrcg = ref("育人成果")

function xunke(){
  router.push('/xhome/xclass')
}
function xunqin(){
  router.push('/xhome/patrol')
}
function dsyr(){
  router.push('/jsyr/addjsyr')
}
function jstd(){
  router.push('/jsjd/addjsjd')
}
function zygx(){
  router.push('/resourceshare')
}
function ai(){
  router.push('/ai')
}

function more_cg(){
  router.push("/cqust/yrcg")
}

function sjksh(){
  router.push("/sjksh/visualization")
}

function rwfb(){
  router.push("/rwfb/xclass")
}
function cqustgw(){
  window.location.replace('https://www.cqust.edu.cn/');
}

function jwxt(){
  window.location.replace('http://casp.cqust.edu.cn/default/index.html#/');
}
</script>

<style scoped>
/* 添加一些样式以适应你的设计 */
img {
  width: 100%;
  height: 100%;
}
.swipe{
  margin-bottom: 15px;
}
.yrcg{
  width: 100%;
}
.yrcg_title{
  overflow: hidden;
  padding: 10px;
  line-height: 18px;
}
.yrcg_span{
  font-size: 18px;
  color: #682757;
  float: left;
}
.yrcg_more{
  font-size: 13px;
  float: right;
}
</style>
